package zhzz;

//这个还没有存储数据也没有对数据的处理仅仅是个跳转
import java.io.Serializable;
import java.util.ArrayList;
import com.example.animaldoctor03.R;
import commonClass.FunctionDispatcher;
import commonClass.QueryAllSymptomsCategorieAndNoBasic_symptomByAnimalIDAction;
import commonClass.RemoteActionsName;
import commonClass.FunctionDispatcher.IRequestCompeletListener;
import Modle.disease.SymptomsCategorie;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class AllInessOfZH extends Activity {
	
	private Button btofAIofzhtochakan = null;
	private ListView listofAIDofzh ;
	
	private String animalID = "01371054603";
	private ArrayList<Object> resultListofAnofzh = null;
	
	private void chushihuaofAIofzh(){
		setContentView(R.layout.allillnessoszh);
		btofAIofzhtochakan = (Button)findViewById(R.id.btoAInessofzh3);

		listofAIDofzh = (ListView)findViewById(R.id.listofAInessofzh);
		
		btofAIofzhtochakan.setOnClickListener(new listenerofAIofzhtock());

	}
	private ArrayList<Object> assembly() {

		ArrayList<Object> list = new ArrayList<Object>();

		list.add(animalID);
		// Integer i = new Integer(10);
		// list.add(i);

		return list;
	}
	private void binding(final ArrayList<Object> list) {
		
		try{	
			String[] resultofZZFZ1 = new String[list.size()];
			// list.toArray(new String[list.size()]);
			for (int i = 0; i < list.size(); i++) {
				
				
				//haiyouwenti
				resultofZZFZ1[i] = ((SymptomsCategorie) list.get(i)).getSymptomsCategorieName();
			}
			ArrayAdapter<String> arrayAdapterofResult = new ArrayAdapter<String>(
					this, android.R.layout.simple_list_item_1, resultofZZFZ1);
			listofAIDofzh.setAdapter(arrayAdapterofResult);
			
			listofAIDofzh.setOnItemClickListener(new OnItemClickListener() {

					public void onItemClick(AdapterView<?> parent, View view, int position,
							long id) {
						// TODO Auto-generated method stub
						Bundle bundleofAIDofzh = new Bundle();
						bundleofAIDofzh.putSerializable("shuju", (Serializable) list.get(position));
						Intent intent = new Intent (AllInessOfZH.this , IllnessDetailofRqst.class);
						intent.putExtras(bundleofAIDofzh);
						startActivity(intent);
						finish();
						
					}
	 
			 });
			 }catch(NullPointerException e){
				 
				 android.app.AlertDialog.Builder builderofZZFZ = new AlertDialog.Builder(AllInessOfZH.this);
				 builderofZZFZ.setMessage("无数据，请用其他功能");
				 builderofZZFZ.create().show();
			 }

	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		chushihuaofAIofzh();
		 assembly();
			ArrayList<Object> parasList = assembly();
			final ArrayList<Object> resultListT = null;
			
			QueryAllSymptomsCategorieAndNoBasic_symptomByAnimalIDAction iAction = new QueryAllSymptomsCategorieAndNoBasic_symptomByAnimalIDAction();

			FunctionDispatcher functionDispacher = new FunctionDispatcher();

			functionDispacher.exceute(
					RemoteActionsName.QueryAllSymptomsCategorieAndNoBasic_symptomByAnimalIDAction, parasList,
					iAction, new IRequestCompeletListener() {

						@Override
						public void doCompelet(ArrayList<Object> resultList) {
							// TODO Auto-generated method stub
							AllInessOfZH.this.resultListofAnofzh = resultList;
							binding(resultListofAnofzh);
						}
					} , this);

		
	}

private class listenerofAIofzhtock implements OnClickListener{

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		Intent intentofAIofzhtoCK = new Intent(AllInessOfZH.this , ChoiceDetail.class);
		startActivity(intentofAIofzhtoCK);
		finish();
		
	}
	
}

}
